home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / DIRS.SWG / 0005_ALLDIRS5.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  1KB  |  47 lines

  1. {
  2. > Can any one tell me a way to make pascal (TP 6.0) search a Complete
  3. > drive, including all subdirectories, even ones that are not in the
  4. > path, looking For a specific File extension?  I.E., having the Program
  5. > search For *.doC and saving that to a Text File?
  6.  
  7. Ok, here goes nothing.
  8. }
  9.  
  10. {$M 65000 0 655360}
  11. {Assign enough stack space For recursion}
  12.  
  13. Program FindAllFiles;
  14.  
  15. Uses Dos;
  16.  
  17. Var
  18.   FileName : Text;
  19.  
  20. Procedure ScanDir(path : PathStr);
  21.  
  22. Var
  23.   SearchFile : SearchRec;
  24. begin
  25.   if Path[Length(Path)] <> '\' then
  26.     Path := Path + '\';
  27.   FindFirst(Path + '*.*', $37, SearchFile); { Find Files and Directories }
  28.   While DosError = 0 do { While There are more Files }
  29.   begin
  30.     if ((SearchFile.Attr and $10) = $10) and (SearchFile.Name[1] <> '.') then
  31.       ScanDir(Path + SearchFile.Name)
  32.       { Found a directory Make sure it's not . or .. Scan this dir also }
  33.     else
  34.     if Pos('.doC',SearchFile.Name)>0 then
  35.       Writeln(FileName, Path + SearchFile.Name);
  36.       { if the .doC appears in the File name, Write path to File. }
  37.     FindNext(SearchFile);
  38.   end;
  39. end;
  40.  
  41. begin
  42.   Assign(FileName,'doCS'); { File to contain list of .doCs }
  43.   ReWrite(FileName);
  44.   ScanDir('C:\'); { Drive to scan. }
  45.   Close(FileName);
  46. end.
  47.